﻿using System;
using System.Runtime.Serialization;

namespace PH.Model.Analyses
{
    [DataContract]
    public class Analysis:MBase
    {
        [Model]
        [DataMember]
        public int ID { get; set; }
        [Model]
        [DataMember]
        public Guid ArchiveGuid { get; set; }
        [Model]
        [DataMember]
        public Nullable<int> Samples { get; set; }
        [Model]
        [DataMember]
        public Nullable<decimal> Gross { get; set; }
        [Model]
        [DataMember]
        public Nullable<int> Fail { get; set; }
        [Model]
        [DataMember]
        public Nullable<int> Pass { get; set; }
        [Model]
        [DataMember]
        public Nullable<int> Good { get; set; }
        [Model]
        [DataMember]
        public Nullable<int> Excellent { get; set; }
        [Model]
        [DataMember]
        public DateTime CreatedOn { get; set; }
        #region Help
        [DataMember]
        public Nullable<decimal> Average
        {
            get {
                return Gross / Samples;
            }
        }
        [DataMember]
        public Nullable<double> FailRate
        {
            get
            {
                return Fail * 1.0 / Samples;
            }
        }
        [DataMember]
        public Nullable<double> PassRate
        {
            get
            {
                return Pass * 1.0 / Samples;
            }
        }
        [DataMember]
        public Nullable<double> GoodRate
        {
            get
            {
                return Good * 1.0 / Samples;
            }
        }
        [DataMember]
        public Nullable<double> ExcellentRate
        {
            get
            {
                return Excellent * 1.0 / Samples;
            }
        }
        [DataMember]
        public Nullable<int> Qualified
        {
            get
            {
                return Excellent + Good + Pass;
            }
        }
        [DataMember]
        public Nullable<double> QualifiedRate
        {
            get { return Qualified * 1.0 / Samples; }
        }
        #endregion
    }
}
